package utils

import (
	"github.com/spf13/viper"
	"storeManageApi/models/authModels"
	"time"
)

type UtilService struct {
	signSecretKey []byte
	outTime       time.Duration
}
type IUtilService interface {
	CreateJWT(auth authModels.UserAuth) (string, error)
	ParseToken(token string) (authModels.JwtUserAuth, error)
}

func CreateUtilService() IUtilService {
	var signSecretKey []byte = []byte(viper.GetString("authBasic.signSecretKey"))
	var outTime time.Duration = viper.GetDuration("authBasic.expiresAt")
	return UtilService{
		signSecretKey: signSecretKey,
		outTime:       outTime,
	}
}
